/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

/**
 * 营销短信 => 营销短信管理
 *  */
import React, { useState, useMemo } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import { connect } from 'umi';
import type { ConnectState } from '@/models/connect';
import { Tabs } from 'antd';
import KbSmsLog from '@/components/_pages/ad/marketingSms/log';
// import KbHistoryLog from '@/components/_pages/ad/marketingSms/history';
import KbSendList from '@/components/_pages/ad/marketingSms/send';

interface IndexType {
  winSize: string;
}

const TemplateAuditIndex = (props: IndexType) => {
  const { winSize } = props;
  const [activeKey, setActiveKey] = useState<string>('send');
  const screenSize = useMemo(() => ['xs', 'sm'].includes(winSize), [winSize]);
  const tabList: any[] = useMemo(
    () => [
      {
        label: '发送营销短信',
        key: 'send',
        children: <KbSendList show={activeKey === 'send'} />,
      },
      {
        label: '发送记录',
        key: 'log',
        children: <KbSmsLog show={activeKey === 'log'} />,
      },
      // {
      //   label: '历史记录',
      //   key: 'history',
      //   children: <KbHistoryLog show={activeKey === 'history'} />,
      // },
    ],
    [activeKey, screenSize],
  );

  const handleTabChange = (current: string) => {
    setActiveKey(current);
  };

  return (
    <PageContainer>
      <Tabs items={tabList} onChange={handleTabChange} />
    </PageContainer>
  );
};

export default connect(({ global }: ConnectState) => ({
  winSize: global.winSize || '',
}))(React.memo(TemplateAuditIndex));
